<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAnnounceTable extends Migration
{
    /**
     * 创建公告表
     *
     * @return void
     */
    public function up()
    {
        Schema::create('announce', function (Blueprint $table) {
            //表属性
            $table->engine = 'InnoDB';
            $table->charset = 'utf8';
            $table->collation = 'utf8_general_ci';
            //表字段
            $table->increments('id');
            $table->integer('cate_id')->comment('公告分类id');
           
            $table->string('sn',45)->comment('公告编号');
            $table->string('title',45)->comment('公告标题');
            $table->string('description',255)->comment('公告描述');
           
            $table->text('content')->comment('公告详情');
           
            $table->integer('user_id')->comment('发布人');
            $table->tinyInteger('is_publish')->defalut(1)->comment('是否发布,1:发布,0:不发布');
           
            $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'))->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('更新时间');
            $table->timestamp('deleted_at')->nullable()->comment('删除时间');
            //创建索引
            $table->unique('sn');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('announce');
    }
}
